load("@io_bazel_rules_go//go:def.bzl", "go_test")
load("//conformance:conformance_test.bzl", "conformance_test")

package(
    licenses = ["notice"],  # Apache 2.0
)

_ALL_TESTS = [
    "@dev_cel_expr//tests/simple:testdata/basic.textproto",
    "@dev_cel_expr//tests/simple:testdata/bindings_ext.textproto",
    "@dev_cel_expr//tests/simple:testdata/comparisons.textproto",
    "@dev_cel_expr//tests/simple:testdata/conversions.textproto",
    "@dev_cel_expr//tests/simple:testdata/dynamic.textproto",
    "@dev_cel_expr//tests/simple:testdata/encoders_ext.textproto",
    "@dev_cel_expr//tests/simple:testdata/enums.textproto",
    "@dev_cel_expr//tests/simple:testdata/fields.textproto",
    "@dev_cel_expr//tests/simple:testdata/fp_math.textproto",
    "@dev_cel_expr//tests/simple:testdata/integer_math.textproto",
    "@dev_cel_expr//tests/simple:testdata/lists.textproto",
    "@dev_cel_expr//tests/simple:testdata/logic.textproto",
    "@dev_cel_expr//tests/simple:testdata/macros.textproto",
    "@dev_cel_expr//tests/simple:testdata/math_ext.textproto",
    "@dev_cel_expr//tests/simple:testdata/namespace.textproto",
    "@dev_cel_expr//tests/simple:testdata/optionals.textproto",
    "@dev_cel_expr//tests/simple:testdata/parse.textproto",
    "@dev_cel_expr//tests/simple:testdata/plumbing.textproto",
    "@dev_cel_expr//tests/simple:testdata/proto2.textproto",
    "@dev_cel_expr//tests/simple:testdata/proto2_ext.textproto",
    "@dev_cel_expr//tests/simple:testdata/proto3.textproto",
    "@dev_cel_expr//tests/simple:testdata/string.textproto",
    "@dev_cel_expr//tests/simple:testdata/string_ext.textproto",
    "@dev_cel_expr//tests/simple:testdata/timestamps.textproto",
    "@dev_cel_expr//tests/simple:testdata/type_deduction.textproto",
    "@dev_cel_expr//tests/simple:testdata/unknowns.textproto",
    "@dev_cel_expr//tests/simple:testdata/wrappers.textproto",
    "@dev_cel_expr//tests/simple:testdata/block_ext.textproto",
]

_TESTS_TO_SKIP = [
    "comparisons/eq_literal/eq_mixed_types_error,eq_list_elem_mixed_types_error,eq_map_value_mixed_types_error",
    "comparisons/ne_literal/ne_mixed_types_error",
    "comparisons/in_list_literal/elem_in_mixed_type_list_error",
    "comparisons/in_map_literal/key_in_mixed_key_type_map_error",
    "macros/exists/list_elem_type_exhaustive,map_key_type_exhaustive",

    # Failing conformance tests.
    "fields/qualified_identifier_resolution/map_key_float,map_key_null,map_value_repeat_key",
    "fields/qualified_identifier_resolution/map_value_repeat_key_heterogeneous",
    "macros/map/map_extract_keys",
    "timestamps/duration_converters/get_milliseconds",
    "optionals/optionals/map_optional_select_has",

    # Temporarily failing tests, need a spec update
    "string_ext/value_errors/indexof_out_of_range,lastindexof_out_of_range",

    # Future enhancments.
    "enums/strong_proto2",
    "enums/strong_proto3",

    # Type deductions
    "type_deductions/wrappers/wrapper_promotion_2",
    "type_deductions/legacy_nullable_types/null_assignable_to_message_parameter_candidate",
    "type_deductions/legacy_nullable_types/null_assignable_to_duration_parameter_candidate",
    "type_deductions/legacy_nullable_types/null_assignable_to_timestamp_parameter_candidate",
    "type_deductions/legacy_nullable_types/null_assignable_to_abstract_parameter_candidate",
]

go_test(
    name = "go_default_test",
    size = "small",
    srcs = [
        "conformance_test.go",
    ],
    tags = [
        "manual",
        "notap",
    ],
    deps = [
        "//cel:go_default_library",
        "//common:go_default_library",
        "//common/ast:go_default_library",
        "//common/types:go_default_library",
        "//common/types/ref:go_default_library",
        "//ext:go_default_library",
        "@com_github_google_go_cmp//cmp:go_default_library",
        "@dev_cel_expr//:expr",
        "@dev_cel_expr//conformance:go_default_library",
        "@dev_cel_expr//conformance/proto2:go_default_library",
        "@dev_cel_expr//conformance/proto3:go_default_library",
        "@dev_cel_expr//conformance/test:go_default_library",
        "@io_bazel_rules_go//go/runfiles",
        "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library",
        "@org_golang_google_protobuf//encoding/prototext:go_default_library",
        "@org_golang_google_protobuf//proto:go_default_library",
        "@org_golang_google_protobuf//testing/protocmp:go_default_library",
    ],
)

conformance_test(
    name = "conformance",
    dashboard = False,
    data = _ALL_TESTS,
    skip_tests = _TESTS_TO_SKIP,
)

conformance_test(
    name = "conformance_dashboard",
    dashboard = True,
    data = _ALL_TESTS,
)
